home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_01_03
/
1n03083a
< prev
next >
Wrap
Text File
|
1990-07-30
|
1KB
|
55 lines
/*
* ANSIPRT.C - reads a file with ANSI carriage control characters from STDIN
* and writes an expanded file to STDOUT. Use redirection to
* control input and output.
*/
#include <stdio.h>
#include <string.h>
char inline[1024];
main()
{
char *workptr;
fgets(inline, sizeof(inline), stdin);
while(!feof(stdin))
{
switch(inline[0])
{
case '1': /* formfeed */
fputc('\n',stdout);
fputc('\f',stdout);
break;
case '0': /* double-space */
fputc('\n',stdout);
fputc('\n',stdout);
break;
case '-': /* triple-space */
fputc('\n',stdout);
fputc('\n',stdout);
fputc('\n',stdout);
break;
case '+': /* overwrite */
fputc('\r',stdout);
break;
default: /* single-space by default */
fputc('\n',stdout);
break;
}
workptr = strchr(inline, '\n'); /* Convert LF to CR */
if(workptr != NULL)
*workptr = '\r';
fputs(&inline[1], stdout); /* skip first character */
fgets(inline, sizeof(inline), stdin);
}
}